package com.whu.helpluojia.controller;

import com.whu.helpluojia.common.R;
import com.whu.helpluojia.domain.Consult;
import com.whu.helpluojia.domain.User;
import com.whu.helpluojia.service.ConsultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/consult")
public class ConsultController {

    @Autowired
    private ConsultService consultService;

    @PostMapping
    private void addConsult(@RequestBody Consult consult){

        consultService.addConsult(consult);
        System.out.println("consult:"+consult);

    }

    @GetMapping("/{id}")
    private Consult getConsultById(@PathVariable Long id) {
        Consult consult = consultService.queryConsultById(id);
        return consult;
    }

    @PostMapping("/recommend")
    private List<User> recommend(@RequestBody Consult consult){
        List<User> users=consultService.getRecommend(consult.getType());
        return users;
    }

    @GetMapping("/selectAll")
    private List<Consult> getConsultAll(){
        return consultService.selectAll();
    }
}
